package com.dyw.ycgovfinance.util.viewutil;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.WindowManager;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;
import com.youth.banner.loader.ImageLoader;

/**
 * Created by Administrator on 2017/3/6.
 */

public class PicassoBannerLoader extends ImageLoader{
    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
        int pathValue = 0;
        int targetWidth = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();

        String urlString = "";
        if(path instanceof Integer)
            pathValue = (Integer)path;
        else if(path instanceof String)
            urlString = (String) path;

        if (pathValue != 0)
            Picasso.with(context)
                    .load(pathValue)
                    .transform(new BitmapTransformation3(context,targetWidth))
                    .config(Bitmap.Config.RGB_565)
                    .into(imageView);
        else
            Picasso.with(context).load(urlString)
                    .transform(new BitmapTransformation3(context,targetWidth))
                    .config(Bitmap.Config.RGB_565)
                    .into(imageView);
    }


}
